package day0624;

import java.util.Arrays;
import java.util.Scanner;

public class Test4 {
    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
        System.out.println("请输入容量:");
        double[]  a=new double[0];
        double sum=0;
        for (int i = 0; 1<6; i++) {
            System.out.println("请输入元素：");
            double d=s.nextDouble();
            if(d<0){break;}

            a=Arrays.copyOf(a,  a.length+1);
            a[i]=d;
            sum=sum+a[i];
        }
        System.out.println(sum/a.length);
    }
}
